#!/usr/bin/python
'''
Created by Colin Gillespie <c.gillespie@ncl.ac.uk>

Last Changed on: $Date$ 
'''

__revision__ = '$Revision$'

import sys

#Import non-standard modules
import OutputAsMaple
import GlobalVariables


def usage():
    print 'usage: python MomentClosure.py -f <file> -o <output> -c <closure>\n'
    print '\tfile is a level 2 SBML file'
    print '\toutput: where to write the maple output - default /tmp/tmp.txt'
    print '\tclosure: the moment closure order - postive integer, default 2'
    sys.exit(2)

def passArguments():
    import getopt
    try:
        opts, args = getopt.getopt(sys.argv[1:], \
            "h:f:o:c:", ["help", "file", "output", "closure"])
    except getopt.GetoptError:
        # print help information and exit:
        usage()

    if not opts:
        usage()

    file_name = None
    closure_order = 2
    output_file = "/tmp/tmp.mw"
    output_format = 'GSL'

    for o, a in opts:
        if o in ("-h", "--help"):
            usage()
            sys.exit()
        if o in ("-f", "--file"):
            file_name = a
        if o in ("-c", "--closure"):
            closure_order = int(a)
        if o in ("-o", "--output_file"):
            output_file = a
    
    if not file_name:
        usage()
    
    g = GlobalVariables
    g.globalVariables(closure_order = closure_order, output_format = output_format)
    OutputAsMaple.createMapleFile(file_name, output_file)
    return 'Maple file created: %s' % output_file



if __name__ == '__main__':
    print passArguments()

